package com.example.airquality.air.controller;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.airquality.air.entity.District;
import com.example.airquality.air.entity.QualityIndex;
import com.example.airquality.air.service.IDistrictService;
import com.example.airquality.air.service.IQualityIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * @author 韩志龙
 * @version 1.0
 * @description: TODO
 * @date 2021/5/21 22:05
 */
@Controller
@RequestMapping("/update")
public class UpdateController {
    @Autowired
    private IDistrictService iDistrictService;
    @Autowired
    private IQualityIndexService iQualityIndexService;
    @RequestMapping("/toUpdateQuality")
    public String toUpdateQuality(Model model,Integer qualityId){
        List<District> districtList = iDistrictService.list();
        QualityIndex qualityIndex = iQualityIndexService.find(qualityId);
        model.addAttribute("districtList",districtList);
        model.addAttribute("qualityIndex",qualityIndex);
        return "update";
    }
    @RequestMapping("/updateQuality")
    public String setQualityId(QualityIndex qu,@RequestParam("qualityId") Integer qualityId){
        int i = iQualityIndexService.setQualityId(qu, qualityId);
        return "redirect:/qualityIndex/toFindAll";
    }

}
